#ifndef __VIEW_H__
#define __VIEW_H__

#include <vector>
#include <fstream>

#include "MRect.h"
#include "IEvent.h"
#include "Primitive.h"

class Window;

//#define DRAWBORDER

class View : public MouseEvents
{
public:
								View( MRect rect = MRect( ) );
	virtual						~View();
	
	void						addSubView( View* view );

	// remove only for window need to fix!!!
	void						removeSubView( View* view );

	View*						subViewAtIndex( unsigned index );
	unsigned					countSubViews();
	void						removeAllSubViews();
	void						deleteAllSubViews();
	// 

	View*						superView();
	void						setSuperView( View* view );
	Window*						window();
	void						setWindow( Window* window );

	virtual void				update();
	
	void						setRect( MRect& rect );
	MRect						rect();
	
	void						setVisible( bool visible );
	bool						visible();

	View*						hitDistantView( MPoint point );

	//void						didEndMovingAnimation( void* param );
#ifdef _DEBUG
	//void						dumpView();
	//virtual std::wstring		description();
#endif

public:
	View*						_superView;
	Window*						_window;		// weak

	std::vector< View* >		_subViews;
	MRect						_rect;

	bool						_visible;
	unsigned					_alpha;

private:
	bool						_canHit;
#ifdef DRAWBORDER
	Primitive*					_border;
	void						drawBorder();
#endif
};

#endif